import { get, put } from '@/utils/request'
import type { Channel, Article } from '@/types/data'
enum API {
  getUserChannel = '/user/channels', //获取用户频道数据
  getAllChannel = '/channels', //获取说有频道数据
  getArticleList = '/articles' //获取文章列表
}
export default class DataServe {
  //获取用户频道数据
  static getUserChannel() {
    return get<{ channels: Array<Channel> }>(API.getUserChannel)
  }
  //获取说有频道数据
  static getAllChannel() {
    return get<{ channels: Array<Channel> }>(API.getAllChannel)
  }
  // 更新用户频道列表
  static updateUserChannels(data: { channels: Array<Channel> }) {
    return put<{ channels: Array<Channel> }>(API.getUserChannel, data)
  }
  // 获取文章列表
  static getArticleList(data: { channel_id: number; timestamp: number }) {
    return get<{ results: Array<Article>; pre_timestamp: string }>(API.getArticleList, { params: data })
  }
}
